//
//  ImageTxtDetailsController.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/10/12.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "ImageTxtDetailsController.h"
#import <WebKit/WebKit.h>

@interface ImageTxtDetailsController ()<WKNavigationDelegate>

{
    MBProgressHUD *_progressHUD;
}

@end

@implementation ImageTxtDetailsController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = UIRectEdgeNone;
}


- (void)setHtmlStr:(NSString *)htmlStr
{
    _htmlStr = htmlStr;
    
    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH,HEIGHT-64)];
//    NSString *temp = [NSString stringWithFormat:@"<head><style>img{max-width:%lfpx !important;}</style></head>%@",WIDTH, self.htmlStr];
    [webView loadHTMLString:self.htmlStr baseURL:nil];
    [self.view addSubview:webView];
    
    webView.navigationDelegate = self;
}

// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
{
    //菊花加载
    _progressHUD = [MBProgressHUD loadingInformationToView];
    [self.view addSubview:_progressHUD];
}
// 当内容开始返回时调用
//- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation;
// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
    [_progressHUD hide:YES];
}
// 页面加载失败时调用
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation
{
    NSLog(@"%@",navigation)
}

@end
